package com.itlong.cloud.smartcard.resource;

import com.itlong.cloud.POJO.DTO.smartcard.SmartCardOldDeviceInfoDTO;
import com.itlong.cloud.POJO.DTO.smartcard.SmartCardOldGetDevicesPageDTO;
import com.itlong.cloud.POJO.DTO.smartcard.SmartCardOldUpdateDeviceInfoDTO;
import com.itlong.cloud.POJO.VO.smartcard.SmartCardOldDeviceInfoVO;
import com.itlong.cloud.smartcard.service.ISmartCardOldDeviceInfoService;
import com.itlong.cloud.user.smartcard.ISmartCardOldDeviceServiceClient;
import com.itlong.cloud.utils.page.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <desc>
 *      旧一卡通_更新电梯楼层对应表数据接口暴露实现类。
 * <desc/>
 *
 * @createDate 2017/11/22.
 */
@RestController
public class SmartCardOldDeviceServiceResource implements ISmartCardOldDeviceServiceClient{

    @Autowired
    ISmartCardOldDeviceInfoService iSmartCardOldDeviceInfoService;
    /**
     * <desc>
     *      更新楼层对应表。
     * <desc/>
     *
     * @param  saveDTO 请求参数
     * @return 返回影响行数
     * @author shengen.T
     * @createDate 2017/11/22
     */
    @Override
    @RequestMapping(path = "/device/deviceInfo/manage/editFloorConfig",method = RequestMethod.POST)
    public Integer updateFloorConfig(@RequestBody SmartCardOldDeviceInfoDTO saveDTO) throws Exception{
          return iSmartCardOldDeviceInfoService.updateFloorConfig(saveDTO);
    }

    /**
     * <desc>
     *      旧_一卡通获取设备列表。
     * <desc/>
     *
     * @param  pageDTO
     * @return
     * @author shengen.T
     * @createDate 2017-12-05
     */
    @Override
    @RequestMapping(path = "/device/deviceInfo/manage/list",method = RequestMethod.POST)
    public Page<SmartCardOldDeviceInfoVO> getDevicePage(SmartCardOldGetDevicesPageDTO pageDTO) throws Exception{
        return iSmartCardOldDeviceInfoService.getDevicePage(pageDTO);
    }

    /**
     * <desc>
     *      旧_一卡通更新设备信息。
     * <desc/>
     *
     * @param updateDTO 更新设备信息参数
     * @return
     * @author shengen.T
     * @createDate 2017-12-12
     */
    @Override
    @RequestMapping(path = "/device/deviceInfo/manage/updateDevice",method = RequestMethod.POST)
    public boolean updateDeviceInfo(@RequestBody SmartCardOldUpdateDeviceInfoDTO updateDTO) throws Exception{
        return iSmartCardOldDeviceInfoService.updateDeviceInfo(updateDTO);
    }


    /**
     * <desc>
     *      旧一卡通_添加设备。
     * <desc/>
     *
     * @param  deviceInfo 设备信息
     * @return
     * @author shengen.T
     * @createDate 2017-12-12
     */
    @Override
    @RequestMapping(path = "/device/deviceInfo/manage/addDevice",method = RequestMethod.POST)
    public boolean addDeviceInfo(@RequestBody SmartCardOldUpdateDeviceInfoDTO deviceInfo) throws Exception{
        return iSmartCardOldDeviceInfoService.addDeviceInfo(deviceInfo);
    }


    /**
     * <desc>
     * 获取某项目中的设备唯一码列表
     * <desc/>
     *
     * @param projectId  项目编号
     * @param deviceType 设备类型：1-电梯，2-门禁
     * @return
     * @author Chunjian.G
     * @createDate 2017-12-15
     */
    @Override
    @RequestMapping(path = "/device/deviceInfo/manage/getDeviceUniques",method = RequestMethod.POST)
    public List<String> getDeviceUniques(@RequestParam("projectId") String projectId,
                                          @RequestParam("deviceType") Integer deviceType) throws Exception {
        return iSmartCardOldDeviceInfoService.getDeviceUniques(projectId, deviceType);
    }

    /**
     * <desc>
     * 添加默认设备信息
     * <desc/>
     *
     * @param deviceUniques 设备唯一码列表
     * @param deviceType    设备类型：1-电梯，2-门禁
     * @param projectId 项目编号
     * @return
     * @author Chunjian.G
     * @createDate 2017-12-15
     */
    @Override
    @RequestMapping(path = "/device/deviceInfo/manage/addDefaultDevices",method = RequestMethod.POST)
    public Integer addDefaultDevices(@RequestBody List<String> deviceUniques,
                                      @RequestParam("deviceType") Integer deviceType,
                                      @RequestParam("projectId") String projectId) throws Exception {
        return iSmartCardOldDeviceInfoService.addDefaultDevices(deviceUniques, deviceType, projectId);
    }
}
